package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderProcessIdVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderProcessUpdateStatusVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderProcessNamePageVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderPurchaseProcessContractPageVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderPurchaseProcessUpdateVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderPurchaseProcessVO;
import com.ssy.lingxi.order.model.vo.process.response.BasePurchaseProcessVO;
import com.ssy.lingxi.order.model.vo.process.response.OrderProcessPageQueryVO;
import com.ssy.lingxi.order.model.vo.process.response.OrderPurchaseProcessContractQueryVO;
import com.ssy.lingxi.order.model.vo.process.response.OrderPurchaseProcessDetailVO;
import com.ssy.lingxi.order.service.web.IOrderPurchaseProcessService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 系统能力 - 采购流程规则配置相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-25
 */
@RestController
@RequestMapping("/order/purchase/process")
public class OrderPurchaseProcessController {
    @Resource
    private IOrderPurchaseProcessService orderPurchaseProcessService;

    /**
     * 分页查询采购流程规则
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderProcessPageQueryVO>> pagePurchaseProcesses(@RequestHeader HttpHeaders headers, @Valid OrderProcessNamePageVO pageVO) {
        return orderPurchaseProcessService.pagePurchaseProcesses(headers, pageVO);
    }

    /**
     * 新增采购规则页面 - 查询基础采购流程列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/base/list", method = RequestMethod.GET)
    public Wrapper<List<BasePurchaseProcessVO>> listBasePurchaseProcess(@RequestHeader HttpHeaders headers) {
        return orderPurchaseProcessService.listBasePurchaseProcess(headers);
    }

    /**
     * 新增采购流程规则
     * @param headers HttpHeaders信息
     * @param processVO 接口参数
     * @return 新增结果
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Wrapper<Void> createPurchaseProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderPurchaseProcessVO processVO) {
        return orderPurchaseProcessService.createPurchaseProcess(headers, processVO);
    }

    /**
     * 查询采购流程规则详情
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<OrderPurchaseProcessDetailVO> getPurchaseProcess(@RequestHeader HttpHeaders headers, @Valid OrderProcessIdVO idVO) {
        return orderPurchaseProcessService.getPurchaseProcess(headers, idVO);
    }

    /**
     * 分页查询采购流程规则适用合同列表
     * @param headers HttpHeaders信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/contract/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderPurchaseProcessContractQueryVO>> pagePurchaseProcessProducts(@RequestHeader HttpHeaders headers, @Valid OrderPurchaseProcessContractPageVO pageVO) {
        return orderPurchaseProcessService.pagePurchaseProcessProducts(headers, pageVO);
    }

    /**
     * 修改采购流程规则
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updatePurchaseProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderPurchaseProcessUpdateVO updateVO) {
        return orderPurchaseProcessService.updatePurchaseProcess(headers, updateVO);
    }

    /**
     * 修改采购流程规则状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/status/update", method = RequestMethod.POST)
    public Wrapper<Void> updatePurchaseProcessStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProcessUpdateStatusVO statusVO) {
        return orderPurchaseProcessService.updatePurchaseProcessStatus(headers, statusVO);
    }

    /**
     * 删除采购流程规则
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deletePurchaseProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProcessIdVO idVO) {
        return orderPurchaseProcessService.deletePurchaseProcess(headers, idVO);
    }
}
